<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>

<div id="main_overWo_list" class="easyui-layout" fit="true">
    <div region="center" style="padding:0px;border:0px">
		<div region="center" style="padding:0px;border:0px;height:100%;">
	        <t:datagrid name="overWoList" title="已办结工单列表"
	                    actionUrl="woController.do?woOverListGrid"
	                   treegrid="false" idField="id" pagination="true" sortOrder="asc" sortName="createDatetime" onLoadSuccess="" pageSize="15">
	            <t:dgCol title="工单来源" field="woSrcDesc" width="60" ></t:dgCol>
	            <t:dgCol title="工单编号" field="id" width="100"></t:dgCol>
		        <t:dgCol title="联系人 " field="contactMan" width="80" query="true"></t:dgCol>
		        <t:dgCol title="联系电话 " field="contactPhone" width="80" query="true"></t:dgCol>
		        <t:dgCol title="工单状态" field="woStateDesc" width="60" ></t:dgCol>
		        <t:dgCol title="处理人员" field="doUsername" width="60" query="true"></t:dgCol>
		        <t:dgCol title="创建时间 " field="createDatetime"  width="80" formatter="yyyy.MM.dd hh:mm:ss"></t:dgCol>
		        <t:dgCol title="common.operation" field="opt" width="120"></t:dgCol>
		        <t:dgFunOpt funname="showWoDetail(id)" title="工单详情"></t:dgFunOpt>
	            <t:dgFunOpt funname="processWoDetail(id)" title="工单回访"></t:dgFunOpt>
	        </t:datagrid>
        </div>
    </div>
</div>


<script type="text/javascript">

	$(function() {
		
	    $('#overWoList').datagrid({  
		   onDblClickRow: function (rowIndex, rowData) {  
			   processWoDetail(rowData.id);
		   }
	   });
	    
	});
	
   function showWoDetail(id){
	   createdetailwindow("工单详情","woController.do?woDetailTabs&wo_id=" + id,1210,600);		 
   }
    
    function processWoDetail(id){
 	   $.dialog({  
 		    id: 'LHG1976D',  
 		    title: "工单回访",  
 		    max: true,  
 		    min: true,  
 		    zIndex: getzIndex(),
 		    drag: true,  
 		    resize: true, 
 			width:1210,
 			height: 600, 
 		    content: 'url:'+"woController.do?todoWoTabs&hf=y&o_wo_id=" + id,  
 		    opacity : 0.3,
 			cache:false, 
 		    cancelVal: '关闭',
 		    cancel: true,
 		    button : [ {  
 		        name : "提交",  
 		        focus : true,  
 		        callback : function() {  
 		            iframe = this.iframe.contentWindow;  
 		            var woOpinion = $('#woOpinion', iframe.tabFrame.document).val();  
 		            if(woOpinion.trim()==''){
 		           	    showAlert('请填写处理意见！');
 		             	return false;
 		            } 
 		            
 		            //var tipMsg = '';
 		            //var woState = $('#woState', iframe.tabFrame.document).val(); 
 		            // var woStateTxt =  $('#woState', iframe.tabFrame.document).va();		            
 		            
 		            
 		            $('#saveState', iframe.tabFrame.document).val('1'); 
 		            tipMsg = '确认【归档】吗?';
 		            
 		        	confirmMsg(tipMsg,iframe,this);
 		            return false;
 		        }  
 		    },{  
		        name : "保存",  
		        focus : false,  
		        callback : function() {  
		        	iframe = this.iframe.contentWindow;  
		        	 //保存状态
		            $('#saveState', iframe.tabFrame.document).val('0'); 
		            doTodoForm(iframe);
					 
		        }
		    }] 
 		});
    }
    
    function doTodoForm(frame) {
 	
 		$('#myform', frame.tabFrame.document).form('submit', {
 			success : function(data) {
 				var d = $.parseJSON(data);
 				if (d.success) {
 					var msg = d.msg;
 					tip(msg);
 					reloadTable();
 				};
 			},
 			error:function(data){
 				var d = $.parseJSON(data);
 				if (d.success) {
 					var msg = d.msg;
 					tip(msg);
 				};
 			}
 			
 		});
 	}
    
    function showAlert(msg){
 	   $.dialog({  
 		    id: 'LHG1976C',  
 		    title: "操作提示",  
 		    max: false,  
 		    min: false,  
 		    zIndex: getzIndex(),
 		    drag: false,  
 		    resize: false, 
 			width:200,
 			height: 80, 
 		    content: msg,  
 		    opacity : 0.3,
 			cache:false, 
 		    cancelVal: '关闭',
 		    cancel: true
 		});
    }

    function confirmMsg(msg,frame,dlg){
 	   $.dialog({  
 		    id: 'LHG1978C',  
 		    title: "操作提示",  
 		    max: false,  
 		    min: false,  
 		    zIndex: getzIndex(),
 		    drag: false,  
 		    resize: false, 
 			width:200,
 			height: 80, 
 		    content: msg,  
 		    opacity : 0.3,
 			cache:false, 
 		    cancelVal: '关闭',
 		    cancel: true,
 		    button : [ {  
 		        name : "确定",  
 		        focus : true,  
 		        callback : function() {  
 		        	doTodoForm(iframe); 
 		        	dlg.close();
 		        }  
 		    }] 
 		});
    }
    
    
	
</script>